import request from '@/config/axios'

// 预约订单 VO
export interface AppointmentOrderVO {
  id: number // 订单唯一标识
  serviceId: number // 关联的预约服务表中的id，代表预约的具体服务
  appointmentDate: Date // 预约日期
  startTime: Date // 预约开始时间
  endTime: Date // 预约结束时间
  contactName: string // 联系人姓名
  contactPhone: string // 联系电话
  province: string // 所在市
  city: string // 所在市
  address: string // 详细地址
  remark: string // 备注信息
  status: number // 订单状态，0 下单 1已服务 2已取消 3已拒绝
}

// 预约订单 API
export const AppointmentOrderApi = {
  // 查询预约订单分页
  getAppointmentOrderPage: async (params: any) => {
    return await request.get({ url: `/appointment/order/page`, params })
  },

  // 查询预约订单详情
  getAppointmentOrderById: async (id: number) => {
    return await request.get({ url: `/appointment/order/getById?id=` + id })
  },

  // 新增预约订单
  createAppointmentOrder: async (data: AppointmentOrderVO) => {
    return await request.post({ url: `/appointment/order/create`, data })
  },

  // 修改预约订单
  updateAppointmentOrder: async (data: AppointmentOrderVO) => {
    return await request.post({ url: `/appointment/order/update`, data })
  },

  // 修改预约订单状态
  updateAppointmentOrderStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/appointment/order/updateStatus`, data: data })
  },

  // 删除预约订单
  deleteAppointmentOrderById: async (id: number) => {
    return await request.get({ url: `/appointment/order/delete?id=` + id })
  },

  // 导出预约订单 Excel
  exportAppointmentOrder: async (params) => {
    return await request.download({ url: `/appointment/order/export-excel`, params })
  }
}